<?php
/**
 * Simple interactive test for client class.
 * 
 * @package AP5L
 * @subpackage Http
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPLv3
 * @copyright 2007, Alan Langford
 * @version $Id: ClientTest.php 91 2009-08-21 02:45:29Z alan.langford@abivia.com $
 * @author Alan Langford <alan.langford@abivia.com>
 */

//
// Set include paths
//
$oldPath = get_include_path();
echo 'old path is ' . $oldPath . '<br/>';
$newPath = preg_replace('!([/\\\\])lib([/\\\\])php([^5]|$)!', '$1lib$2php5$3', $oldPath);
echo 'new path is ' . $newPath . '<br/>';
set_include_path($newPath);

//require_once('xmlrpc/XmlRpc.php');

function __autoload($className) {
    $components = explode('_', $className);
    $base = array_shift($components);
    if ($base == 'AP5L' && count($components)) {
        $final = array_pop($components);
        $path = '';
        foreach ($components as $dir) {
            $path .= strtolower($dir) . '/';
        }
        $path .= $final . '.php';
        require_once($path); 
    }
}

$client = new AP5L_Http_Client();
$client -> setOptions(
    array(
        'debug' => 1,
        'url' => 'http://dev.abivia.com',
        'masquerade' => 'ff',
        'params' => array (
            'a' => 'param a',
            'b' => 'param b',
        ),
    )
);
//$client -> execute();

$client -> setOptions(
    array(
        'method' => 'post',
        'host' => 'www.example.com',
        'path' => '/test.html',
        'params' => array (
            'hl' => 'en',
            'ie' => 'UTF8',
            'text' => 'commerce',
            'langpair' => 'en|ru',
        ),
        'header' => array('Referer' => 'http://www.example.com/foo'),
    )
);
$client -> execute();

?>